/*
 * @Author: leao 2788481746@qq.com
 * @Date: 2024-08-27 11:03:14
 * @LastEditors: leao 2788481746@qq.com
 * @LastEditTime: 2024-08-28 11:33:22
 * @FilePath: /sdSys/data-structure/dataStrCode/singleLinkedList/singleLinkedList.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#ifndef __SINGLELINKEDLIST_H_
#define __SINGLELINKEDLIST_H_
#include <stdio.h>
#include <stdlib.h>
#define ERROR_CHECK(ret, num, msg) \
    {                              \
        if (ret == num)            \
        {                          \
            perror(msg);           \
            exit(1);               \
        }                          \
    }
  
typedef int type;
typedef struct singleLinkedList
{
    type data;
    struct singleLinkedList *next;

} ND;
//creat
ND *createList();
//insertNodeHead
void insertNodeHead(ND *header, type val);

/**
 * @brief //insertNodeTail
 * 
 * @param header 
 * @param val 
 */
void insertNodeTail(ND *header, type val);
//showList
void showList(ND *header);
// void showList2(ND header); 传值会导致空间的浪费，未操作到原header；
//del by index
void delNode0(ND *header,int val);
void delNode1(ND *header, int val);

/**
 * @brief //select by val
 * 
 * @param header 
 * @param val 
 * @return ND* 
 */
ND* slectNodeByVal(ND *header,int val);
//changge val
void changeNodeVal(ND *header,int val);
//List length
int lengthList(ND *header);
//is empty  0：空     
int isEmptyList(ND *header);
//init
void initList(ND *header);
//freeList
void freeList(ND **header);
#endif
